#include <iostream>
#include <regex>
#include <string>
#include <fstream>
using namespace std;

int main()
{
    ifstream in{"regex.txt"};
    if (!in)
        cerr << "cannot open regex file\n";

    regex pat{R"(\w{2}\s*\d{5}(-\d{4})?)"};
    int linenu{0};
    for(string line; getline(in, line); )
    {
        ++linenu;
        smatch matches;
        if(regex_search(line, matches, pat))
        {
            cout << linenu << ": " << matches[0] << "\n";
            if(1 < matches.size() && matches[1].matched)
                cout << "\t:" << matches[1] << "\n" ;
        }
    }
    
    return 0;
}